﻿using LM.Negocio.Objetos;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace LM.Repositorios.Maps
{
    public class DependenteMap : EntityTypeConfiguration<Dependente>
    {
        public DependenteMap()
        {
            this.HasKey(m => m.Id);
            this.Property(m => m.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).HasColumnName("Id");
            this.Property(m => m.Codigo).HasColumnName("Codigo").IsRequired();
            this.Property(m => m.Nome).HasColumnName("Nome").IsRequired().HasMaxLength(50);
            this.Property(m => m.Cpf).HasColumnName("Cpf").IsRequired().HasMaxLength(11);
            this.Property(m => m.Cnh).HasColumnName("Cnh").IsRequired().HasMaxLength(13);

            this.HasRequired(m => m.Cliente)
                .WithMany(p => p.Dependentes)
                .HasForeignKey(s => s.IdCliente);

            this.ToTable("DEPENDENTE");
        }
    }
}
